package com.itcz.cli.example;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;

/**
 * picocli第三方工具demo模板
 * name 参数：命令行程序名称
 * version 参数：当前命令行程序版本
 * mixinStandardHelpOptions 参数：true表示开启帮助手册
 */
@Command(name = "ASCIIArt", version = "ASCIIArt 1.0", mixinStandardHelpOptions = true)
public class ASCIIArt implements Runnable { 

    @Option(names = { "-s", "--font-size" }, description = "Font size") 
    int fontSize = 19;

    /**
     * 1）@Parameters 注解的 paramLabel 参数：参数标签，作用类似于描述信息
     * 2）@Parameters 注解的 defaultValue 参数：默认值
     * 3）description 参数：指定描述信息，从而让生成的帮助手册和提示信息更清晰。
     */
    @Parameters(paramLabel = "<word>", defaultValue = "Hello, picocli", 
               description = "Words to be translated into ASCII art.")
    private String[] words = { "Hello,", "picocli" }; 

    @Override
    public void run() {
        // 自己实现业务逻辑
        System.out.println("fontSize = " + fontSize);
        System.out.println("words = " + String.join(",", words));
    }

    public static void main(String[] args) {
        // 通过接收运行时输入的参数来给属性复制
        int exitCode = new CommandLine(new ASCIIArt()).execute(args); 
        System.exit(exitCode); 
    }
}
